package com.andnux.android.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.andnux.android.fragment.PhotoFragment;

import java.util.Arrays;
import java.util.List;

public class PhotoFragmentAdapter extends FragmentStatePagerAdapter {

    private final List<String> photos;

    public PhotoFragmentAdapter(FragmentManager fm, String[] photos) {
        super(fm);
        this.photos = Arrays.asList(photos);
    }

    @Override
    public Fragment getItem(int i) {
        return PhotoFragment.newInstance(photos.get(i));
    }

    @Override
    public int getCount() {
        return photos == null ? 0 : photos.size();
    }
}
